package com.ayou.eggguard.farm.mapper;

import com.ayou.eggguard.farm.pojo.Treatment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TreatmentMapper {
    List<Treatment> getTreatmentList(String coopNumber);

    @Delete("delete from treatment where id=#{id}")
    void delete(Integer id);

    @Insert("insert into treatment (coop_number, blight_name, chicken_type, column_number, storey_number, cage_number, treat_time, action, feature, check_result, diagnose_result, treat_method, treat_result) " +
            "values (#{coopNumber},#{blightName},#{chickenType},#{columnNumber},#{storeyNumber},#{cageNumber},#{treatTime},#{action},#{feature},#{checkResult},#{diagnoseResult},#{treatMethod},#{treatResult});")
    void add(Treatment treatment);

    @Update("update treatment set coop_number=#{coopNumber},blight_name=#{blightName},chicken_type=#{chickenType}," +
            "column_number=#{columnNumber},storey_number=#{storeyNumber},cage_number=#{cageNumber},treat_time=#{treatTime}," +
            "action=#{action},feature=#{feature},check_result=#{checkResult},diagnose_result=#{diagnoseResult},treat_method=#{treatMethod}," +
            "treat_result=#{treatResult} where id=#{id}")
    void update(Treatment treatment);
}
